Add bidirectional form communication API for dashboard apps#453
Add bidirectional form communication API for dashboard apps#453lkostrowski merged 20 commits intomainfrom
Conversation
🦋 Changeset detectedLatest commit: 6d7304a The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #453 +/- ##
==========================================
+ Coverage 84.84% 84.98% +0.14%
==========================================
Files 114 115 +1
Lines 3754 3789 +35
Branches 637 640 +3
==========================================
+ Hits 3185 3220 +35
Misses 557 557
Partials 12 12 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Released snapshot build with Install it with: pnpm add @saleor/[email protected] |
|
Released snapshot build with Install it with: pnpm add @saleor/[email protected] |
ee19175 to
a88ab96
Compare
|
Released snapshot build with Install it with: pnpm add @saleor/[email protected] |
|
Released snapshot build with Install it with: pnpm add @saleor/[email protected] |
|
Released snapshot build with Install it with: pnpm add @saleor/[email protected] |
|
Released snapshot build with Install it with: pnpm add @saleor/[email protected] |
|
Released snapshot build with Install it with: pnpm add @saleor/[email protected] |
witoszekdev
left a comment
There was a problem hiding this comment.
I don't have any comments for code itself, lgtm
I do have some proposal for the API though. As far as I understand, we will receive updates for all forms in dashboard inside the app? 🤔
appBridge.subscribe("formPayload", (payload) => {
if (payload.form === "product-translate") {
I would probably add possibility to subscribe to only specific forms, or single form at a time, so that we don't have handlers that listen to only one form, but get events for all of them.
I would probably add possibility to subscribe to only specific forms, or single form at a time, so that we don't have handlers that listen to only one form, but get events for all of them. It's likely not possible because app is mounted on the single context, so you have sinlge form. You can't have open app that is listening to translate product and edit product, because they are different views |
Summary
This PR introduces a new experimental API for bidirectional communication between Saleor dashboard forms and apps. This enables apps to receive form context and update form fields programmatically.
Key Features
New Form Communication API
formPayloadevent, including current field values, metadata, and form contextformPayloadUpdateaction, allowing them to:Supported Forms
Type-Safe Implementation
Technical Changes
New Files
src/app-bridge/form-payload.ts: Core types and constants for form communicationModified Files
src/app-bridge/actions.ts: AddedFormPayloadUpdateactionsrc/app-bridge/events.ts: AddedFormDataEventfor form payloadsrc/app-bridge/app-bridge-state.ts: Updated state managementExample Usage
Notes
This is an experimental API and may be subject to changes based on feedback and usage patterns.